package com.assessment.web;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.assessment.dto.AssessmentIndexDTO;
import com.assessment.entity.AssessmentIndex;
import com.assessment.service.IAssessmentIndexService;
import com.common.util.AJAXResultMessage;
import com.common.util.ExtjsPageable;
import com.syslog.aop.SystemServiceLog;


@Controller
@RequestMapping("/assessmentIndex")
public class AssessmentIndexController 
{
	@Autowired
	private IAssessmentIndexService assessmentIndexService;
	
	@SystemServiceLog("新增或修改考核模板指标")
	@RequestMapping("/saveOrUpdate")
	public @ResponseBody AJAXResultMessage saveOrUpdate(AssessmentIndexDTO assessmentIndexDTO) 
	{
		try {
			assessmentIndexService.saveOrUpdate(assessmentIndexDTO);
    		return new AJAXResultMessage(true,"操作成功!");
	    } catch (Exception e) {
	    	e.printStackTrace();
	        return new AJAXResultMessage(false,"操作失败!");
	    }
	}
	@SystemServiceLog("删除考核模板的考核指标")
	@RequestMapping(value = "/delete")
    public @ResponseBody AJAXResultMessage delete(Long id) {
    	try {
    		assessmentIndexService.delete(id);
    		return new AJAXResultMessage(true,"操作成功!");
	    } catch (Exception e) {
	    	e.printStackTrace();
	        return new AJAXResultMessage(false,"操作失败!");
	    }
    }
	
	@SystemServiceLog("查看考核模板的考核指标")
	@RequestMapping("/findAll")
	public @ResponseBody Page<AssessmentIndexDTO> findAll(Long id,ExtjsPageable pageable) 
	{
		Page<AssessmentIndexDTO> page =assessmentIndexService.findAll(id,pageable.getPageable());				
		return page;		
	}
	
}
